package cn.dlc.com.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.dlc.com.config.Config;
import cn.dlc.com.server.ZookeeperServer;

@RestController
@RequestMapping("config")
public class ConfigContoller {
	
	/**
	 * 发起请求，将这个东西进行改变（用来模拟配置信息的变化）
	 * @param config
	 * @return
	 */
	@PostMapping("change")
	public String changeConfig(@RequestBody Config config) throws Exception{
		ZookeeperServer zkConfigMng = new ZookeeperServer();
		zkConfigMng.update(new Config("jdbc:mysql://192.168.182.93:3306/demo?useUnicode=true&characterEncoding=utf-8",
				"root", "root", "com.mysql.jdbc.Driver"));
		return "ok";
	}
}
